var gStartupFunctions = new Array();

String.prototype.trim = function() { 
	return this.replace(/^[\s\u3000]+|[\s\u3000]+$/g, ''); 
}

function registerStartupFunction( pFunction ) {
	if( pFunction ) gStartupFunctions[gStartupFunctions.length] = pFunction;	
}

function doOnLoad() {
	for(var i=0; i<gStartupFunctions.length; ++i) {
		gStartupFunctions[i]();
	}	
}
onload=doOnLoad;

/* after this don't use onload= to assign startup functions,
	instead use registerStartupFunction( functionName ); */

function getElementsByClass(pClass, pContainer) {
	pContainer = pContainer||document;
	var allTags = pContainer.all||pContainer.getElementsByTagName('*');
	var result = new Array();

	for(var i=0; i<allTags.length; ++i) {
		if( allTags[i].className == pClass)
			result[result.length] = allTags[i];
	}
	return result;
} 

function getEventTarget(e) {
	if (!e) var e = window.event;
	var tg = (window.event) ? e.srcElement : e.target;
	return tg;
}

function getFirstChildOfType(elem, nodeName, recurse) {
	if( !elem.hasChildNodes() ) return null;
		
	elem=elem.childNodes[0];
	while( elem ) {
		if(elem.nodeName == nodeName)
			return elem;
				
		elem=elem.nextSibling;
	}
	return null;
}
